/**
 * @author LinYiSong
 */
$(function() {
	if ($(".bd-left").attr("name") == "1") {
		$("#employee").hide();
	} else if ($(".bd-left").attr("name") == "0") {
		$("#admin").hide();
	}
	clickBtn();
	toSection();
	closeAll();
});
function clickBtn() {
	$(".btn").click(
			function(event) {
				var length = $(this).parent(".title").children(".icon").css(
						"background-position").split(" ")[1].length;
				var y = $(this).parent(".title").children(".icon").css(
						"background-position").split(" ")[1].substring(0,
						length - 2);

				var e = $(event.target).attr("name");
				if (e == 0) {
					y = parseInt(y) + 32;
					var xy = $(this).parent(".title").children(".icon").css(
							"background-position").split(" ")[0]
							+ " " + y + "px";
					$(this).parent(".title").children(".icon").css(
							"background-position", xy);
					$(this).parent(".title").parent().children(".detaillist")
							.show();
					$(event.target).attr("name", 1);
				} else if (e == 1) {
					y = parseInt(y) - 32;
					var xy = $(this).parent(".title").children(".icon").css(
							"background-position").split(" ")[0]
							+ " " + y + "px";
					$(this).parent(".title").children(".icon").css(
							"background-position", xy);
					$(this).parent(".title").parent().children(".detaillist")
							.hide();
					$(event.target).attr("name", 0);
				}
			});
}

function toSection() {
	$("a").click(function() {
		var e = $(this).attr("name");
		$("#bd .bd-right iframe").attr("src", e);
	});
}
function closeAll() {
	$(".btn").each(function() {
		$(this).parent(".title").parent().children(".detaillist").hide();
	});
}

function closeWindow() {
	window.opener=null;
	window.close();
}